// 统一管理用户管理相关的接口
import request from "../../request";
// ts数据类型
import type { MenuParams, PermissionResponseData } from "./type";

enum API {
  // 获取全部菜单与按钮的标识数据
  ALLPERMISSION_URL = "/admin/acl/permission",
  ADDMENU_URL = "/admin/acl/permission/save",
  UPDATE_URL = "/admin/acl/permission/update",
  DELETEMENU_URL = "/admin/acl/permission/remove/",
}

// 获取菜单数据
export const reqAllPermission = () =>
  request.get<any, PermissionResponseData>(API.ALLPERMISSION_URL);

export const reqAddOrUpdateMenu = (data: MenuParams) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATE_URL, data);
  } else {
    return request.post<any, any>(API.ADDMENU_URL, data);
  }
};

export const reqRemoveMenu = (id: number) =>
  request.delete<any, any>(API.DELETEMENU_URL + id);
